package model.tokens;

import java.util.Deque;
import java.util.Queue;
import java.util.Stack;

import model.semantics.Node;

/**
 * Literals are one of: integer values or variables.
 * 
 * @param <T>
 */

public abstract class LiteralToken<T> extends NodeToken<T> {

    public LiteralToken(TokenConstructorArguments<T> args) {
        super(args);
    }

    @Override
    public void process(Automaton<T> state) {
        // Two literals can't occur next to each other unless they're function
        // arguments.
        // To this effect, shunt functions to output if this happens.
        if (state.lastToken instanceof LiteralToken) {
            shuntFunctionsToOutput(state.operatorStack, state.output);
        }

        // Just push constants to the output queue.
        state.output.add(makeNewInstance(state.output));
    }

    @Override
    public abstract Node<T> makeNewInstance(Deque<Node<T>> nodes);
}
